#ifndef OPERATIONDELEGATE_H
#define OPERATIONDELEGATE_H

#include <QStyledItemDelegate>
#include <QPushButton>
#include <QApplication>

class OperationDelegate : public QStyledItemDelegate
{
    Q_OBJECT

public:
    explicit OperationDelegate(QObject *parent = nullptr);

    void paint(QPainter *painter, const QStyleOptionViewItem &option,
               const QModelIndex &index) const override;
    QSize sizeHint(const QStyleOptionViewItem &option,
                   const QModelIndex &index) const override;
    bool editorEvent(QEvent *event, QAbstractItemModel *model,
                     const QStyleOptionViewItem &option, const QModelIndex &index) override;

signals:
    void uploadClicked(int row);
    void deleteClicked(int row);
    void viewClicked(int row);

private:
    //按钮信息描述大小的矩形尺寸
    mutable QRect m_uploadRect;
    mutable QRect m_deleteRect;
    mutable QRect m_viewRect;

    QRect getButtonRect(const QRect &cellRect, int buttonIndex) const;
};

#endif // OPERATIONDELEGATE_H
